import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

import vuexpersist from "vuex-persist"

export default new Vuex.Store({
  state: {
    res: [{
      id: '1',
      content: '圣诞的钟声敲响,鹿儿的蹄声回荡,温暖的歌声送上,圣诞来到.',
      num: 0
    }, {
      id: '2',
      content: '愿你:"圣"下快乐,"圣"下健康,"圣"下吉祥。问君能有几多喜?',
      num: 0
    }, {
      id: '3',
      content: '圣诞钟声还尚早,祝福知多少?短信发出刚不久,又有祝福铃声在叨扰',
      num: 0
    }, {
      id: '4',
      content: '圣诞到,鹿儿跑,铃儿响叮当;雪花飘,鸟儿叫,树儿尽妖娆;',
      num: 1
    }, {
      id: '5',
      content: '幸福的时光就让它凝聚,祝平安快乐幸福如意!',
      num: 1
    }, {
      id: '6',
      content: '寒冷忘却遥望月光的思念,清翠的松柏身裹银色的衣,微风摇摆吹落点点思念。',
      num: 1
    }, {
      id: '7',
      content: '星星许下二个心愿;一是愿天下所有人平安快乐,另一个则是告诉正在看此讯息嘀幸运娃',
      num: 2
    }, {
      id: '8',
      content: '健康的体魄是树根,幸福的家庭是树干,顺心的事业是树枝,美满的爱情是树叶,辉煌的成就是树冠,惬意的生活是树荫!',
      num: 2
    }, {
      id: '9',
      content: '朋友久别情不断,圣诞问候爱更甜,平安狂欢,尽情欢,切莫把爱藏起来。',
      num: 2
    }]
  },
  mutations: {
    OneUp1(state,index){
      state.res[index].num=1
    },
    twoUp1(state, index) {
      state.res[index].num=0
    },
    twoUp2(state, index) {
      state.res[index].num = 2
    },
    threeUp(state, index) {
      state.res[index].num=1
    },
    all3(state) {
      state.res.forEach(res => {
        if (res.num == 2) {
          res.num=0
        }
      })
    },
    all2(state) {
      state.res.forEach(res => {
        if (res.num == 1) {
          res.num = 2
        }
      })
    },
    all1(state) {
      state.res.forEach(res => {
        if (res.num == 0) {
          res.num = 1
        }
      })
    }
  },
  actions: {
  },
  modules: {
  },
 plugins:[
    new vuexpersist({
    storage:window.localStorage,
  }).plugin,
],
})
